package cn.cqautotest.cqviehelper.views;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.zhuangfei.timetable.TimetableView;
import com.zhuangfei.timetable.listener.ISchedule;
import com.zhuangfei.timetable.listener.OnItemBuildAdapter;
import com.zhuangfei.timetable.model.Schedule;

import cn.cqautotest.cqviehelper.adapters.MyOnDateBuildAdapter;

public class MyTimetableView extends TimetableView {

    private ISchedule.OnDateBuildListener onDateBuildListener;//日期栏构建监听
    private ISchedule.OnItemBuildListener onItemBuildListener;//课程表item构建监听

    /**
     * 初始化
     *
     * @param context
     * @param attrs
     */
    public MyTimetableView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    /**
     * 获取日期栏构建监听器
     *
     * @return
     */
    public ISchedule.OnDateBuildListener onDateBuildListener() {
        if (onDateBuildListener == null) onDateBuildListener = new MyOnDateBuildAdapter();
        return onDateBuildListener;
    }

    /**
     * 获取Item构建监听器，可以更改 Item 的角标显示
     *
     * @return
     */
    public ISchedule.OnItemBuildListener onItemBuildListener() {
        if (onItemBuildListener == null) onItemBuildListener = new OnItemBuildAdapter() {
            @Override
            public void onItemUpdate(FrameLayout layout, TextView textView, TextView countTextView, Schedule schedule, GradientDrawable gd) {
                super.onItemUpdate(layout, textView, countTextView, schedule, gd);
                countTextView.setVisibility(GONE);
            }
        };
        return onItemBuildListener;
    }
}
